import { getRequest, postRequest } from "../baseRequest";
import request, { requestHttp } from "@/utils/request";
import { ResultData } from "@/api/types";

// 查询我的待填写表单列表
export const listTodo = (params: any) => getRequest("/user/form/todo/page", params);

// 查询表单待填写表单列表
export const listAllTodo = (params: any) => getRequest("/user/form/todo/pageAll", params);

// 分配给用户
export const assignTodo = (data: any) => postRequest("/user/form/todo/assign", data);

// 删除待填写表单
export const delTodo = (data: any) => postRequest("/user/form/todo/delete", data);

// 填写任务
export interface TodoFormTask {
  id?: number;
  name?: string;
  formKey?: string;
  description?: string;
  percentageValue?: number;
  completedCount?: number;
  totalCount?: number;
}

// 查询待填写表单列表
export const listTaskTodo = (params: any): Promise<ResultData> => requestHttp.get("/user/form/todo/task/page", params);

// 导出
export const exportTaskTodo = (params: any) => {
  return request({
    url: "/user/form/todo/export",
    method: "get",
    responseType: "blob",
    params: params
  });
};

// 添加待办
export const addTaskTodo = (params: TodoFormTask) => requestHttp.post("/user/form/todo/task/add", params);

// 分配给用户
export const updateTaskTodo = (data: TodoFormTask) => requestHttp.post("/user/form/todo/task/update", data);

// 删除待填写表单
export const delTaskTodo = (data: any) => requestHttp.post("/user/form/todo/task/delete", data);

// 催办
export const remindTodo = (data: { id: number; type: number; formKey: string; params: any }) =>
  postRequest("/user/form/todo/task/remind", data);
